import { request } from "@/utils/http";
import { DepartmentList, DictItems, GetScheduleListParams, GetScheduleRuleListParams, GetScheduleRuleListReponse, HospitalListParams, HospitalListResponse, HospitalShowResponse, ScheduleList } from "./types";
import { Key } from "react";

/**
 * 获取所有的省份信息
 * @returns 
 */
export function getProvinces(){
  return request.get<any, DictItems>('/admin/cmn/dict/findByDictCode/Province');
}

/**
 * 根据省份 id 获取对应城市列表或区县列表
 * @param parentId 省份 id
 * @returns 
 */
export function getCitiesOrDistrict(parentId: Key){
  return request.get<any, DictItems>(`/admin/cmn/dict/findByParentId/${parentId}`);
}

/**
 * 获取医院类型的数据
 * @returns 
 */
export function getHosTypes(){
  return request.get<any, DictItems>('/admin/cmn/dict/findByDictCode/Hostype');
}

/**
 * 获取医院的列表数据
 * @param param HospitalListParams
 * @returns 
 */
export function getHospitalList({page, limit, ...args}: HospitalListParams){
  return request.get<any, HospitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`, {
    params: args
  })
}

/**
 * 获取医院的详细信息
 * @param hosid 医院的 id 
 * @returns Promise
 */
export function getHospitalShow(hosid: string){
  return request.get<any, HospitalShowResponse>(`/admin/hosp/hospital/show/${hosid}`);
}


/* 
获取部门列表
GET /admin/hosp/department/{hoscode}
*/
// export function reqGetDeparmentList(hoscode: string) {
//   return request.get<any, DepartmentList>(`/admin/hosp/department/${hoscode}`)
// }

export const reqGetDeparmentList = (hoscode: string) => request.get<any, DepartmentList>(`/admin/hosp/department/${hoscode}`)

/* 
获取排班规则列表
GET /admin/hosp/schedule/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}
*/
export const reqGetScheduleRuleList = ({
  page,
  limit,
  hoscode,
  depcode
}: GetScheduleRuleListParams) => request.get<any, GetScheduleRuleListReponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)

/* 
获取排班列表
GET /admin/hosp/schedule/findScheduleList/{hoscode}/{depcode}/{workDate}
*/
export const reqGetScheduleList = ({
  workDate,
  hoscode,
  depcode
}: GetScheduleListParams) => request.get<any, ScheduleList>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)

